import { Http } from "@/utils/request";
import { Toast } from "@/utils/toast";
import { delayTask } from "@/utils/timer";

const baseUrl = "/new_guide";

export const follow_tour_product_header_api = (showError = true) => {
  return Http.get<{ items: any[] }>(
    `/v3${baseUrl}/follow_tour_product_header`
  ).catch((error: Error) => {
    showError && delayTask(60, () => Toast.show(error.message));
    return Promise.reject(error);
  });
};

export const follow_tour_product_items_api = (
  data: { province_id: number } & MiniApp.PagingQuery,
  showError = true
) => {
  return Http.get<MiniApp.PagingData>(
    `/v3${baseUrl}/follow_tour_product_items`,
    data
  ).catch((error: Error) => {
    showError && delayTask(60, () => Toast.show(error.message));
    return Promise.reject(error);
  });
};
